﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
namespace BUS
{
    public class NguoiMuaBUS
    {
        public static void INSERT(NguoiMua D)
        {
            NguoiMuaDAL DAL = new NguoiMuaDAL();
            DAL.INSERT(D);
        }
        public static void UPDATE(NguoiMua D)
        {
            NguoiMuaDAL DAL = new NguoiMuaDAL();
            DAL.UPDATE(D);
        }
        public static void UpdateTrangThai(string user, int trangthai)
        {
            NguoiMuaDAL DAL = new NguoiMuaDAL();
            DAL.UpdateTrangThai(user, trangthai);
        }
        public static void DELETE(string iD)
        {
            NguoiMuaDAL DAL = new NguoiMuaDAL();
            DAL.DELETE(iD);
        }
        public static NguoiMuaCollection GETALL()
        {
            NguoiMuaDAL DAL = new NguoiMuaDAL();


            int TotalRecords = 0;
            return DAL.GET("where 1=1", 0, 0,
                            NguoiMuaColumn.TenDangNhap_NguoiMua.ToString(),
                            "ASC", out TotalRecords);
        }
        public static NguoiMuaCollection GET(string Where, int PageIndex, int PageSize, string OrderBy, string OrderDirection, out int TotalRecords)
        {
            NguoiMuaDAL DAL = new NguoiMuaDAL();
            return DAL.GET(Where, PageIndex, PageSize, OrderBy, OrderDirection, out TotalRecords);
        }
        public static NguoiMua GetById(string iD)
        {
            int total = 0;
            NguoiMuaDAL DAL = new NguoiMuaDAL();
            NguoiMuaCollection Collection = DAL.GET("where " + NguoiMuaColumn.TenDangNhap_NguoiMua.ToString() + "='" + iD + "'", 0, 0, NguoiMuaColumn.TenDangNhap_NguoiMua.ToString(), "ASC", out total);
            if (Collection.Count > 0)
                return Collection[0];
            return null;
        }
    }
}
